<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content" style="height: 100px">
        <form class="form-horizontal m" id="form-teachPersonalDocuments-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">文件名：</label>
				<div class="col-sm-8">
					<input id="filePath" name="filePath" class="form-control" type="file">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "teach/teachPersonalDocuments"

		function submitHandler() {
			if ($.validate.form()) {
				uploadFile();
			}
		}

		function uploadFile() {
			var formData = new FormData();
			if ($('#filePath')[0].files[0] == null) {
				$.modal.alertWarning("请先选择文件路径");
				return false;
			}
			formData.append('file', $('#filePath')[0].files[0]);
			formData.append('remark',$("#remark").val());
			$.ajax({
				url: prefix + "/add",
				type: 'post',
				cache: false,
				data: formData,
				processData: false,
				contentType: false,
				dataType: "json",
				success: function(result) {
					$.operate.successCallback(result);
				}
			});
		}
	</script>
</body>
</html>
